/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package basan.core;

import basan.components.IComponent;
import basan.components.LocationComponent;
import sim.types.ObjectType;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author Menno @ Basans
 */
public class GameObject implements Entity {
    private LocationComponent location;
    
    //Gamespecific types
    private ObjectType type;
    
    private List<IComponent> components;
    
    public GameObject() {
        location = new LocationComponent(0, 0, 0);      
        init();
    }    
    
    public GameObject(float x, float y, float z) {
        location = new LocationComponent(x, y, z);
        init();
    }
    
    private void init(){
        type = ObjectType.NONE;
        components = new LinkedList<IComponent>();
    }
    
    public LocationComponent getLocation() {
        return location;
    }
    
    @Override
    public void think() {        
        for(IComponent c : components)
             c.think();
    }
    
    @Override
    public void update(){
        for(IComponent c : components)
             c.update();        
    }
    
    @Override
    public void lateUpdate(){
        for(IComponent c : components)
             c.lateUpdate();        
    }

    public void addComponent(IComponent comp) {
        components.add(comp);
    }
    
    
    public ObjectType getType() {
        return type;
    }
    
    public void setType(ObjectType type) {
        this.type = type;
    }
}
